home *** CD-ROM | disk | FTP | other *** search
- // GptCGM2.cpp - more cgmObject class funtions
- // copyright 1992 Pittsburgh Supercomputing Center
-
- #include "gpt.h"
- #include "cgm.h" // basic display classes
- #include "cgmdisp.h" // basic display classes
- #include "gptDisp.h"
-
-
- // *** CgmObject::DisplayCurPic - display current picture
- void cgmObject::DisplayCurPic(HWND hWnd, RECT *rect, Scroller *sbars)
- {
- PAINTSTRUCT ps;
- pcDisplay *myPC;
- HDC hdcMeta;
- HDC hdc = BeginPaint(hWnd, &ps);
-
- if (hMeta) // if Metafile exists ( so does hMemDC)
- {
- StretchBlt( hdc, 0, 0,rect->right, rect->bottom, hMemDC,
- +sbars->getnHscrollPos(),+sbars->getnVscrollPos(),
- rect->right, rect->bottom,SRCCOPY);
- EndPaint(hWnd, &ps);
- //MakeBitmapMeta(hWnd, rect, sbars); OBSOLETE CODE
- return;
- }
-
- // no metafile
- if (!curPic) // Bad CGM ??
- {
- EndPaint(hWnd,&ps);
- return;
- }
-
- HourGlass(hWnd); // Turn on hourglass cursor
- HDC hdcInfo = CreateDC("DISPLAY", NULL, NULL, NULL);
- hdcMeta = CreateMetaFile(NULL);
- myPC = new pcDisplay(cgmWin,hdc,hdcMeta, hdcInfo,rect);
- myPC->setExtent(rect); // Set Extent for GPlot code
- myPC->backColr2(); // Make Background white
-
- curPic->display( (BaseDisplayPt)myPC); // Display using myPC's functions
- lastPic = curPic;
- //MakeStar(hdc , hdcMeta); // for fun
- myPC->clip( FALSE); // turn off clipping
- myPC->ExtentRect(); // And draw border
- delete myPC;
- EndPaint(hWnd, &ps);
- hMeta = CloseMetaFile(hdcMeta);
- DeleteDC( hdcInfo);
-
- if (!curPic->next) cgmMeta->setIndexed();
-
- // At this point have a Windows Metafile which is bunch of drawing
- // primatives. This should be device independent, but it draws slowly
- // and also clip rectangels do not seem to scroll along with other
- // graphics when metafile is played.
-
- // Play metafile on a memory device - use memory device to scroll picture
- hdc = GetDC(hWnd);
- hCompBit = CreateCompatibleBitmap(hdc,GetSystemMetrics(SM_CXSCREEN),
- GetSystemMetrics(SM_CYSCREEN) - GetSystemMetrics(SM_CYCAPTION)
- - GetSystemMetrics(SM_CYMENU));
- hMemDC = CreateCompatibleDC(hdc);
- hOldBit = SelectObject( hMemDC, hCompBit);
- PlayMetaFile(hMemDC,hMeta); // Play metafile in memory
- ReleaseDC(hWnd, hdc);
- HourGlass(hWnd);
- }
- // ************************** Junk for Test ****************************
- // *** CgmObject::MakeStar - Draw Star in left hand corner of picture
- //Not Used
- void cgmObject::MakeStar(HDC hdc, HDC hdcMeta)
- {
- POINT *points = new POINT[20];
- points[0].x = 32; points[0].y = 0;
- points[1].x = 16; points[1].y = 63;
- points[2].x = 63; points[2].y = 16;
- points[3].x = 0; points[3].y = 16;
- points[4].x = 48; points[4].y = 63;
- HDC hMemoryDC = CreateCompatibleDC(hdc);
- HBITMAP hBitmap, hOldBitmap;
- hBitmap = CreateCompatibleBitmap(hdc, 64,64);
- hOldBitmap = SelectObject(hMemoryDC, hBitmap);
- PatBlt(hMemoryDC,0,0,64,64,WHITENESS);
- Polygon(hMemoryDC, points,5);
- BitBlt(hdc,0,0,64,64,hMemoryDC,0,0,SRCCOPY);
- BitBlt(hdcMeta,0,0,64,64,hMemoryDC,0,0,SRCCOPY);
- SelectObject(hMemoryDC, hOldBitmap);
- DeleteDC(hMemoryDC);
- DeleteObject(hBitmap);
- delete []points;
- }
- // !!! Not Used
- // *** CgmObject::MakeBitmapMeta - Make Metafile which is copy of screen bitmap
- void cgmObject::MakeBitmapMeta(HWND hWnd, RECT *rect, Scroller *sbars)
- {
- HDC hdcMeta, hdc;
- if (!DidFullMeta && sbars->IsFullSize()) // can make bit metafile
- {
- // Make new Metafile which is just bitmap xfer
- DidFullMeta = TRUE;
- DeleteMetaFile(hMeta);
- hdcMeta = CreateMetaFile(NULL);
- hdc = GetDC(hWnd);
- HBITMAP hBit= CreateCompatibleBitmap(hdc,rect->right, rect->bottom);
- HDC hMemoryDC = CreateCompatibleDC(hdc);
- HBITMAP hBitOld = SelectObject( hMemoryDC, hBit);
- BOOL foobar =
- StretchBlt(hMemoryDC, 0, 0,rect->right, rect->bottom, hdc,0,0,
- rect->right, rect->bottom,SRCCOPY);
- foobar =
- StretchBlt(hdcMeta, 0, 0,rect->right, rect->bottom, hMemDC,0,0,
- rect->right, rect->bottom,SRCCOPY);
- hMeta = CloseMetaFile(hdcMeta);
- SelectObject(hMemoryDC, hBitOld);
- DeleteDC(hMemoryDC);
- DeleteObject(hBit);
- ReleaseDC(hWnd, hdc);
- }
- }
-
-
-